'use strict';

const Service = require('egg').Service;
const OpenAI = require('openai');

class OpenAIService extends Service {
  async getDeepseek(prompt) {
    // Example method to interact with OpenAI API
    const { ctx } = this;
    const openai = new OpenAI({
        baseURL: "https://api.deepseek.com",
        apiKey: "sk-8ef88ace087f4e6a9b39788bd478858c",
      });
    
    const completion = await openai.chat.completions.create({
        messages: [{ role: "system", content: prompt }],
        model: "deepseek-chat",
      });
    
    // console.log(completion.choices[0].message.content);
    return completion.choices[0].message.content;
  }
}

module.exports = OpenAIService;
